var t = getApp();

Component({
    properties: {
        DataInfo: {
            type: null
        },
        isType: {
            type: null
        }
    },
    data: {
        show_levels_CheckedAll: !1,
        buy_levels_CheckedAll: !1,
        show_groups_CheckedAll: !1,
        buy_groups_CheckedAll: !1,
        show1: !1,
        show2: !1,
        show3: !1,
        show4: !1,
        levelsList: [],
        buy_levels: [],
        show_levels: [],
        groupsList: [],
        show_groups: [],
        buy_groups: [],
        once_buy_limit: "0",
        total_buy_limit: "0",
        day_buy_limit: "0",
        week_buy_limit: "0",
        month_buy_limit: "0",
        hyll_Model: [],
        hygm_Model: [],
        hyzll_Model: [],
        hyzgm_Model: []
    },
    lifetimes: {
        attached: function() {},
        moved: function() {},
        detached: function() {},
        ready: function() {
            var t = this.properties.isType;
            this.setData({
                isType: t
            }), this.data.isType && this.getDataInfo();
        }
    },
    attached: function() {},
    ready: function() {},
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        getDataInfo: function() {
            var e = this, s = t.getNetAddresss("plugin.store-cashier.frontend.store.goods.get-store-goods-setting");
            t._postNetWork({
                url: s,
                success: function(s) {
                    var a = s.data;
                    if (1 == a.result) {
                        if (e.setData({
                            levelsList: a.data.member_level,
                            groupsList: a.data.member_group
                        }), !e.properties.isType) {
                            var l = e.properties.DataInfo.privilege;
                            console.log(l, "有值？"), t._isTextEmpty(l) ? console.log("刚刚开启") : (e.setData({
                                hyll_Model: l.show_levels,
                                hygm_Model: l.buy_levels,
                                show_levels: l.show_levels,
                                buy_levels: l.buy_levels
                            }), e.setData({
                                hyzll_Model: l.show_groups,
                                hyzgm_Model: l.buy_groups,
                                show_groups: l.show_groups,
                                buy_groups: l.buy_groups
                            }), e.setData({
                                once_buy_limit: String(l.once_buy_limit),
                                total_buy_limit: String(l.total_buy_limit),
                                day_buy_limit: String(l.day_buy_limit),
                                week_buy_limit: String(l.week_buy_limit),
                                month_buy_limit: String(l.month_buy_limit)
                            }));
                        }
                    } else wx.showToast({
                        icon: "none",
                        title: a.msg || "错误",
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t.msg);
                }
            });
        },
        change: function(t) {
            this.setData({
                show_levels: t.detail
            }), this.data.show_levels.length == this.data.levelsList.length ? this.setData({
                show_levels_CheckedAll: !0
            }) : this.setData({
                show_levels_CheckedAll: !1
            });
        },
        listCheckAllChange: function(t) {
            this.setData({
                buy_levels: t.detail
            }), this.data.buy_levels.length == this.data.levelsList.length ? this.setData({
                buy_levels_CheckedAll: !0
            }) : this.setData({
                buy_levels_CheckedAll: !1
            });
        },
        showGroupsChange: function(t) {
            this.setData({
                show_groups: t.detail
            }), this.data.show_groups.length == this.data.groupsList.length ? this.setData({
                show_groups_CheckedAll: !0
            }) : this.setData({
                show_groups_CheckedAll: !1
            });
        },
        buyGroupsChange: function(t) {
            this.setData({
                buy_groups: t.detail
            }), this.data.buy_groups.length == this.data.groupsList.length ? this.setData({
                buy_groups_CheckedAll: !0
            }) : this.setData({
                buy_groups_CheckedAll: !1
            });
        },
        checkAll: function(t) {
            if (this.setData({
                show_levels_CheckedAll: t.detail
            }), this.data.show_levels_CheckedAll) {
                var e = this.data.levelsList, s = [];
                e.forEach(function(t) {
                    s.push(t.level_name);
                }), this.setData({
                    show_levels: s
                });
            } else this.setData({
                show_levels: []
            });
        },
        checkAllBuyLevels: function(t) {
            if (this.setData({
                buy_levels_CheckedAll: t.detail
            }), this.data.buy_levels_CheckedAll) {
                var e = this.data.levelsList, s = [];
                e.forEach(function(t) {
                    s.push(t.level_name);
                }), this.setData({
                    buy_levels: s
                });
            } else this.setData({
                buy_levels: []
            });
        },
        checkAllShowGroups: function(t) {
            if (this.setData({
                show_groups_CheckedAll: t.detail
            }), this.data.show_groups_CheckedAll) {
                var e = this.data.groupsList, s = [];
                e.forEach(function(t) {
                    s.push(t.group_name);
                }), this.setData({
                    show_groups: s
                });
            } else this.setData({
                show_groups: []
            });
        },
        checkAllBuyGroups: function(t) {
            if (this.setData({
                buy_groups_CheckedAll: t.detail
            }), this.data.buy_groups_CheckedAll) {
                var e = this.data.groupsList, s = [];
                e.forEach(function(t) {
                    s.push(t.group_name);
                }), this.setData({
                    buy_groups: s
                });
            } else this.setData({
                buy_groups: []
            });
        },
        PermissionsJson: function() {
            var t;
            t = {
                show_levels: this.data.show_levels,
                buy_levels: this.data.buy_levels,
                show_groups: this.data.show_groups,
                buy_groups: this.data.buy_groups,
                once_buy_limit: this.data.once_buy_limit,
                total_buy_limit: this.data.total_buy_limit,
                day_buy_limit: this.data.day_buy_limit,
                week_buy_limit: this.data.week_buy_limit,
                month_buy_limit: this.data.month_buy_limit
            }, this.triggerEvent("getChildtwoData", t, {
                bubbles: !1
            });
        },
        showPopup: function(t) {
            var e = parseInt(t.target.dataset.index || t.currentTarget.dataset.index);
            switch (this.triggerEvent("CoverLayer", !0, {
                bubbles: !1
            }), e) {
              case 1:
                this.setData({
                    show1: !0
                }), this.data.isType || (this.setData({
                    show_levels: this.data.hyll_Model
                }), this.data.show_levels.length == this.data.levelsList.length ? this.setData({
                    show_levels_CheckedAll: !0
                }) : this.setData({
                    show_levels_CheckedAll: !1
                }));
                break;

              case 2:
                this.setData({
                    show2: !0
                }), this.data.isType || (this.setData({
                    buy_levels: this.data.hygm_Model
                }), this.data.buy_levels.length == this.data.levelsList.length ? this.setData({
                    buy_levels_CheckedAll: !0
                }) : this.setData({
                    buy_levels_CheckedAll: !1
                }));
                break;

              case 3:
                this.setData({
                    show3: !0
                }), this.data.isType || (this.setData({
                    show_groups: this.data.hyzll_Model
                }), this.data.show_groups.length == this.data.groupsList.length ? this.setData({
                    show_groups_CheckedAll: !0
                }) : this.setData({
                    show_groups_CheckedAll: !1
                }));
                break;

              case 4:
                this.setData({
                    show4: !0
                }), this.data.isType || (this.setData({
                    buy_groups: this.data.hyzgm_Model
                }), this.data.buy_groups.length == this.data.groupsList.length ? this.setData({
                    buy_groups_CheckedAll: !0
                }) : this.setData({
                    buy_groups_CheckedAll: !1
                }));
                break;

              default:
                this.setData({
                    show1: !1,
                    show2: !1,
                    show3: !1,
                    show4: !1
                });
                var s = this.data.hyll_Model, a = this.data.hygm_Model, l = this.data.hyzll_Model, i = this.data.hyzgm_Model;
                a = this.data.buy_levels, s = this.data.show_levels, l = this.data.show_groups, 
                i = this.data.buy_groups, this.setData({
                    hyll_Model: s,
                    hygm_Model: a,
                    hyzll_Model: l,
                    hyzgm_Model: i
                }), this.triggerEvent("CoverLayer", !1, {
                    bubbles: !1
                });
            }
        },
        isCoverLayer: function() {
            this.setData({
                show1: !1,
                show2: !1,
                show3: !1,
                show4: !1
            }), this.triggerEvent("CoverLayer", !1, {
                bubbles: !1
            });
        },
        onChangenum: function(t) {
            this.setData({
                once_buy_limit: t.detail.value
            });
        },
        onChangetoaut: function(t) {
            this.setData({
                total_buy_limit: t.detail.value
            });
        },
        onChangebuy: function(t) {
            this.setData({
                day_buy_limit: t.detail.value
            });
        },
        onChangeweek: function(t) {
            this.setData({
                week_buy_limit: t.detail.value
            });
        },
        onChangemonth: function(t) {
            this.setData({
                month_buy_limit: t.detail.value
            });
        }
    }
});